import sys
sys.path.append("H:\\anacoda\\Lib\\site-packages")
import baostock as bs
import pandas as pd
import time

def getStockPd(cdoe, head, startDate, endDate):
    time.sleep(2)
    # 登陆放在了min上暂时不用lg = bs.login()
    # head:"date,code,open,high,low,close,preclose,volume,amount,adjustflag,turn,tradestatus,pctChg,isST"
    rs = bs.query_history_k_data_plus(cdoe, head,
                                      start_date=endDate, end_date=startDate,
                                      frequency="d", adjustflag="3")
    data_list = []
    while (rs.error_code == '0') & rs.next():
        # 获取一条记录，将记录合并在一起
        data_list.append(rs.get_row_data())
    result = pd.DataFrame(data_list, columns=rs.fields)
    return result
